<?php	
	require_once 'models/models_hoadon.php';
	$mod = $_GET['mod'];
	$obHD = new models_hoadon();
	require_once 'models/models_khachhang.php';
	$obKH = new models_khachhang();
	switch ($mod){
		case 'hoadon':{
			$data['listhd'] = $obHD->_listHoaDonn();
			$data['listkh'] = $obKH->_listkhachhang();
			require_once 'views/admin/hoadon/index.php';
			break;
		}
		case 'add_hoadon':{
			if($_POST){
				$obHD->_addHoaDon($_POST['cmb_khachhang'], $_POST['ngaylap'], $_POST['nguoilap']);
				echo '<script>window.location.href="admin.php?mod=hoadon"</script>';
			}
			$data['listkh'] = $obKH->_listkhachhang();
			require_once 'views/admin/hoadon/add.php';
			break;
		}
		case 'del_hoadon':{
			$obHD->_delHoaDon($_GET['id']);
			echo '<script>window.location.href="admin.php?mod=hoadon"</script>';
			break;
		}
		case 'edit_hoadon':{
			if($_POST){
				$obHD->_editHoaDon($_POST['cmb_khachhang'], $_POST['ngaylap'], $_POST['nguoilap'], $_GET['id']);
				echo '<script>window.location.href="admin.php?mod=hoadon"</script>';
			}
			$data = $obHD->_getHoaDon($_GET['id']);
			$data['listkh'] = $obKH->_listkhachhang();
			require 'views/admin/hoadon/edit.php';
			break;
		}
	}
?>